{% extends "xadmin/my_base.html" %}
{% block body%}
<div class="container">
    <!-- Button trigger modal -->
    <button type="button" class="btn btn-primary pull-right" data-toggle="modal" data-target="#newRepositoryModal">
        添加仓库
    </button>

    <table class="table table-hover">
        <thead>
            <th style="width:1%"></th>
            <th style="width:30%"></th>
            <th style="width:60%"></th>
        </thead>
        <tbody>
            {% for index, repo in repositories %}
            <tr>
                <td>{{index}}</td>
                <td><a href="{% url 'repository:repository_main' repo.id%}">{{repo.name}}</a></td>
                <td>{{repo.path}}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    <!-- Modal -->
    <div class="modal fade" id="newRepositoryModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
        aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">创建新仓库</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" method="POST" id="new_repository_form" action="{% url 'repository:add_repository' %}">
                        {% csrf_token %}
                        <div class="form-group">
                            <label for="repository_name" class="col-sm-2 control-label">仓库名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="repository_name" name="repository_name" autofocus
                                    placheholder="新增仓库的名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="repository_description" class="col-sm-2 control-label">仓库描述</label>
                            <div class="col-sm-10">
                                <textarea rows="7" class="form-control" id="repository_description" name="repository_description" style="resize:none;"
                                    placheholder="仓库的具体描述信息">
                                </textarea>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary glyphicon glyphicon-remove-circle" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary glyphicon glyphicon-ok-circle" onclick="form_submit()">提交</button>
                </div>
            </div>
        </div>
    </div>


</div>
{% endblock %}

{% block script %}
<script type="text/javascript">
function form_submit(){
    $("#new_repository_form").submit();
}

</script>
{% endblock %}